package com.bjwl.service.impl;

import com.bjwl.dao.AdminMapper;
import com.bjwl.pojo.Admin;
import com.bjwl.service.AdminService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Author: czc
 * @Date:Create：in 2020/4/10 15:13
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adMapper;

    @Override
    public Integer ByIdUpdateuser(Admin admin) {
        return adMapper.ByIdUpdateadmin(admin);
    }

    @Override
    public void addAdmin(Admin admin) {
        admin.setCratetime(new Date());
        adMapper.addAdmin(admin);
    }

    @Override
    public void deleteAdmin(Integer id) {
        adMapper.deleteAdmin(id);
    }

    @Override
    public PageBean<Admin> findAllAdmin(Integer pageNum, String username) {
        PageBean<Admin> pageBean = new PageBean<Admin>(pageNum, 10, adMapper.getTotalRecord(username));
        pageBean.setData(adMapper.findAllAdmin(pageBean, username));

        return pageBean;
    }

    @Override
    public Admin findAdminByUserNameAndPassWord(Admin admin) {
        Admin admin1 = adMapper.findAdminByUserNameAndPassWord(admin);
        return admin1;
    }

    @Override
    public Admin findAdminById(Admin admin) {
        return adMapper.findAdminById(admin);
    }

    @Override
    public void adminState(Admin admin) {
        adMapper.adminState(admin);
    }

    @Override
    public Integer findAllAdminTotalRecord() {
        return adMapper.findAllAdminTotalRecord();
    }

    @Override
    public List<Admin> findAdminByUserName(String userName) {
        return adMapper.findAdminByUserName(userName);
    }


}
